home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8614 / 8614.xpi / modules / utils / PrivateBrowsing.jsm < prev    next >
Text File  |  2010-02-10  |  2KB  |  42 lines

  1. // DO NOT import this into the global namespace, but instead
  2. // import it into your own namespace wrapper
  3.  
  4. var EXPORTED_SYMBOLS = ["PrivateBrowsingListener"];
  5.  
  6. Components.utils.import("resource://glydo/utils/prototype_xul_1_6_0_3_modified.jsm");
  7. Components.utils.import("resource://glydo/utils/Utils.jsm");
  8. Components.utils.import("resource://glydo/utils/Events.jsm");
  9.  
  10. var PrivateBrowsingListener = Prototype.Class.create(EventSource,{
  11.     initialize : function ($super) {
  12.         $super();
  13.         this.os = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  14.         this.inPrivateBrowsing = false;
  15.         this.os.addObserver(this, "private-browsing", false);  
  16.         this.os.addObserver(this, "quit-application", false);  
  17.         try {  
  18.             var pbs = Components.classes["@mozilla.org/privatebrowsing;1"].getService(Components.interfaces.nsIPrivateBrowsingService);  
  19.             this.inPrivateBrowsing = pbs.privateBrowsingEnabled;  
  20.         } catch(ex) {  
  21.             // ignore exceptions in older versions of Firefox  
  22.         }  
  23.     },  
  24.  
  25.     observe : function (aSubject, aTopic, aData) {
  26.         if (aTopic == "private-browsing") {
  27.             if (aData == "enter") {
  28.                 this.inPrivateBrowsing = true;
  29.                 this.fire('onEnterPrivateBrowsing');
  30.             } else if (aData == "exit") {
  31.                 this.inPrivateBrowsing = false;
  32.                 this.fire('onExitPrivateBrowsing');
  33.             }
  34.         } else if (aTopic == "quit-application") {
  35.             this.os.removeObserver(this, "quit-application");
  36.             this.os.removeObserver(this, "private-browsing");
  37.         }
  38.     },
  39.  
  40. });
  41.  
  42.